package com.ly.lypopupwindowdemo.adapter;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.ly.lypopupwindowdemo.fragment.TextFragment;

/**
 * Created by liying on 2017/6/5.
 */

public class MyViewPagerAdapter extends FragmentPagerAdapter{

    private String[] titles;
    public MyViewPagerAdapter(FragmentManager fm,String[] titles) {
        super(fm);
        this.titles = titles;
    }

    @Override
    public Fragment getItem(int position) {
        TextFragment fragment = new TextFragment();
        Bundle bundle = new Bundle();
        bundle.putString("title",titles[position]);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public int getCount() {
        return titles.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}
